package redis

import (
	"fmt"
	"github.com/go-redis/redis"
	"userrpc/config"
)

var Rdb *redis.Client

func RedisInit() {
	Rdb = redis.NewClient(&redis.Options{
		Addr:     config.AppConfig.RedisConfig.Host + ":" + config.AppConfig.RedisConfig.Port,
		Password: config.AppConfig.RedisConfig.Password,
		DB:       0,
	})
	err := Rdb.Ping().Err()
	if err != nil {
		fmt.Println("redis连接失败")
		return
	} else {
		fmt.Println("redis连接成功")
	}
}
